package com.chinatsp.onlineapp.ui.violation;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.chinatsp.onlineapp.R;
import com.chinatsp.onlineapp.base.BaseActivity;
import com.chinatsp.onlineapp.base.Config;
import com.chinatsp.onlineapp.presenter.QueryViolationDao;
import com.chinatsp.onlineapp.utils.ActivityUtil;

/**
 * 违章查询
 */
public class QueryViolationActivity extends BaseActivity implements
		View.OnClickListener {

	private ImageView ivEngineNumHelp;
	private ImageView ivEngineNumHelpBottom;
	private Button btnQuery;
	private ViewGroup tvSelectCity;
	private ImageView ivBack;
	private CheckBox cbxRead;
	private QueryViolationDao queryViolationDao;
	private int requestCode = 1;
	private TextView tv_address;
	EditText mEdCarNum;
	@Override
	public void onRequestSuccess(int requestCode) {
		super.onRequestSuccess(requestCode);
		// 开始更新UI
		showProgress(false);
		if (requestCode == Config.CODE_QUERY_VIOLATION) {

		}

	}

	@Override
	public void onRequestFailed(String errorNo, String errorMessage) {
		super.onRequestFailed(errorNo, errorMessage);
		// 开始更新UI
		showProgress(false);
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_query_violation);
		initView();
	}

	private void initView() {
		ivEngineNumHelp = (ImageView) findViewById(R.id.iv_engine_num_help);
		ivEngineNumHelpBottom = (ImageView) findViewById(R.id.iv_engine_num_help_bottom);
		btnQuery = (Button) findViewById(R.id.btn_query);
		tvSelectCity = (ViewGroup) findViewById(R.id.tv_select_city);
		ivBack = (ImageView) findViewById(R.id.iv_back);
		cbxRead = (CheckBox) findViewById(R.id.cbx_read);
		mEdCarNum = (EditText) findViewById(R.id.ed_car_num);
		cbxRead.setChecked(true);
		
		tv_address = (TextView) findViewById(R.id.tv_address);

		queryViolationDao = new QueryViolationDao(this, this);
		//String carNum = "2874052783";
		//showProgress(true);
		//queryViolationDao.getQueryViolation(carNum);

		ivEngineNumHelp.setOnClickListener(this);
		ivEngineNumHelpBottom.setOnClickListener(this);
		btnQuery.setOnClickListener(this);
		tvSelectCity.setOnClickListener(this);
		ivBack.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btn_query:
			ActivityUtil.intentActivity(QueryViolationActivity.this,
					QueryViolationLogActivity.class, null);
			
			
			break;
		case R.id.iv_engine_num_help:
			ActivityUtil.intentActivity(QueryViolationActivity.this,
					HelpActivity.class, null);
			break;
		case R.id.iv_engine_num_help_bottom:
			ActivityUtil.intentActivity(QueryViolationActivity.this,
					HelpActivity.class, null);
			break;
		case R.id.tv_select_city:
			Intent intent = new Intent();
			intent.setClass(this, SelectCityActivity.class);
			startActivityForResult(intent, requestCode);
			break;
		case R.id.iv_back:
			finish();
			break;
		}
	}
	
	
	@Override
	protected void onActivityResult(int arg0, int arg1, Intent date) {
		super.onActivityResult(arg0, arg1, date);
		if (date != null) {
			String selectcityId = date.getStringExtra("selectCityId");
			tv_address.setText(selectcityId);
		}

	}
}
